[求助]VB连接ACCESS查询问题

来源:百度知道 编辑:UC知道 时间:2024/06/26 02:25:28
[求助]VB连接ACCESS查询问题
本人是个学生,毕业设计让做个会员卡系统,我用VB做的连接的是ACCESS数据库,录入的问题解决了,但是修改的问题又出来了,我的修改界面是 想在上面的会员卡号text1里面输入卡号,点击“查询”,就在下面的text控件中显示姓名,性别等等东西 我用的是adodc控件,查询的代码是

if adodc1.recordset("会员卡号").value="text1.text" then

adodc1.recordset("会员姓名").value="text2.text"

adodc1.recordset("会员性别").value="text3.text"

adodc1.recordset("会员积分").value="text4.text"

.........' 中间的都省略了

end if

但是上面的根本不行 ,求教,给个完整的代码也行 ,谁要能给个实例更感激不尽。谢谢先

写错了吧,改为这个看看:

With Adodc1
.RecordSource = "select * from [表名] where 会员卡号 = '"& trim(text1.text) &"'"

if .Recordset.RecordCount>0 then

text2.text=.recordset("会员姓名").value

text3.text=.recordset("会员性别").value

text4.text=.recordset("会员积分").value

.........' 中间的都省略了

end if
end With

先根据text1.text去查找相应的数据,然后按照下面的格式赋值就可以了!text2.text=adodc1.recordset("会员姓名").value

text3.text=adodc1.recordset("会员性别").value
..........